/*
 * Event.java
 *
 * Created on September 16, 2007, 3:12 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package simulationengine.event;

/**
 * The Event Class provides the transaction currency for the scheduler.
 * @author edrucker
 */
public abstract class Event implements Comparable<Event>
{
	
	//entity involved
	private Entity entity;
	
	//event time 
	private double time;
	
	/** Creates a new instance of Event */
	public Event(Entity e, double t)
	{
		entity = e;
		time = t;
	}
	
	
    /**
     * This method is called each time the scheduler fires off an event
     */
	public abstract void occur();
	

	
    /**
     * Is used to compare times, find the current time, and check to see if we've reached the end
     * @return double containing the Current System Time
     */
	public double getTime()
	{
		return time;
	}
	
    /**
     * Used to get the current Entity
     * @return Entity object for current Entity
     */
	public Entity getEntity()
	{
		return entity;
	}
	

    /**
     * Used to implement the <Comparable> Event interface. We compare times of events here
     * @param e Event to compare
     * @return int for whether Event e's time is >, ==, or <
     */
	public int compareTo(Event e)
	{
		if(e.getTime() > this.time)
		{
			return -1;
		}
		else if(e.getTime() == this.time)
		{
			return 0;
		}
		else
		{
			return 1;
		}
	}
}
